<template>

	<div id="">
		<div class="aui-btn aui-btn-outlined" v-show="hasInvoice === 0" @click.stop="exploitBills(orderNo);">
	        开票申请
	    </div>
	</div>
</template>
<script>
	import axios from "axios";
	// import api from "../../api";
	import {Popup, MessageBox} from 'mint-ui';
	import { mapState, mapGetters, mapMutations } from "vuex";
	export default {
		data(){
			return {
				rids:"",
				content:""
				
			}
		},
		props: {
		    hasInvoice: {
		        type: Number,
//		        default: () => {
//		          return false
//		        }
				required:true
		    },
		    orderNo: {
		        type: String,
//		        default: () => {
//		          return false
//		        }
		        required:true
		    },
		    ParentOrderNo: {
		        type: String,
//		        default: () => {
//		          return false
//		        }
		        required:true
		    },
	    },
	    computed: {
		    ...mapGetters('hzh', [
		       'saveBillshead',
		    ]),
	    	...mapGetters('hzh', [
		       'SaveBillContent',
		    ]),
	    },
		components:{
			// "my-header":MyHeader,
		},
		methods: {
            //开票申请
		    exploitBills(val){
		      	console.log("zhouxinsjhige6666",val)
		      	let item = val;
//		      	this.BillAply();
		      	this.$router.push({name:'BillDetail',query:{datas:item,parentOrderNo:this.ParentOrderNo}})	
		      	
		    },
		    async BillAply(){
		    	await this.$store.dispatch('hzh/GetBillheads');
				console.log("saveBillshead/////////",this.saveBillshead,this.orderNo)
				
				this.saveBillshead.forEach(items => {
//					if(items.orderNo == this.orderNo){
						this.rids = items.rid;
						this.content = this.SaveBillContent;
//					}
				})
		    	var sessionId = localStorage.getItem('sessionId');
		    	console.log("content////////",this.SaveBillContent)
	            var url = window.api.local_host + api.BillAplys + this.rids+"/"+ this.content+"/"+ this.ParentOrderNo;
	            console.log(url,"我贼强啊")
	//			var url = "http://test.mall.yn.weilian.cn"+ api.lookUpBills;
	            var config = {
	               url,
	               method: "put",
	               headers: {sessionId},
	            }
	            console.log("qqqqqqqqqqq9",sessionId)
	            await axios(config).then((res) => {
	                console.log("hahahahahahahaha222", res)
	                if(res.data.returnCode === 1){
						this.BillDetails = res.data.data;
//						this.$store.dispatch('hzh/SaveClickAddress', res.data.data);
						
	                }else if(res.data.returnCode === 0){
	                	MessageBox.alert(res.data.errmsg)
//	                	.confirm(res.data.errmsg).then(action => {
//		                   this.$router.push('/login');
//		                });
	                }
	            
	            })
		    }
			
		},
		mounted() {
			
		},
	}
	
	
	
	
	
	
	
	
</script>

<style>
</style>